﻿<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

// Admin 璺敱缁?
Route::prefix('admin')->group(function () {
    // 上传接口（资质图片、logo等）
    Route::post('/upload', 'App\\Admin\\Controllers\\StoreController@upload')->name('admin.upload');

    // 闂ㄥ簵绠＄悊璺敱
    Route::prefix('store')->group(function () {
        Route::post('/store-categories', 'App\\Admin\\Controllers\\StoreController@getCategories')->name('admin.store.categories');
        Route::post('/address', 'App\\Admin\\Controllers\\StoreController@getAddresses')->name('admin.store.address');
        Route::get('/', 'App\\Admin\\Controllers\\StoreController@index')->name('admin.store.index');
        Route::get('/list', 'App\\Admin\\Controllers\\StoreController@list')->name('admin.store.list');
        Route::get('/{id}', 'App\\Admin\\Controllers\\StoreController@detail')->name('admin.store.show');
        Route::post('/get-collection-code', 'App\\Admin\\Controllers\\StoreController@getCollectionCode')->name('admin.store.get-collection-code');
        Route::post('/', 'App\\Admin\\Controllers\\StoreController@store')->name('admin.store.store');
        Route::put('/{id}', 'App\\Admin\\Controllers\\StoreController@update')->name('admin.store.update');
        Route::delete('/{id}', 'App\\Admin\\Controllers\\StoreController@destroy')->name('admin.store.destroy');
    });

});

// 浠庡壇鏈悎骞讹細H5涓庡井淇＄浉鍏砏eb璺敱
use App\Http\Controllers\H5Controller;
use App\Http\Controllers\StoreController;
use App\Http\Controllers\WechatVerifyController;

// H5搴旂敤璺敱
Route::group(['prefix' => 'h5'], function () {
    Route::get('/', [H5Controller::class, 'index'])->name('h5.index');
    Route::get('/wechat/callback', [H5Controller::class, 'wechatCallback'])->name('h5.wechat.callback');
    Route::get('/wechat/config', [H5Controller::class, 'getWechatConfig'])->name('h5.wechat.config');
});

// H5 History 璺敱鍏滃簳锛堟帓闄?/h5/wechat/*銆?h5/assets/*銆?h5/static/* 闈欐€佽祫婧愯矾寰勶級
Route::get('/h5/{any}', [H5Controller::class, 'index'])
    ->where('any', '^(?!wechat\/)(?!assets\/)(?!static\/).*$')
    ->name('h5.history');

// 寰俊鑿滃崟鍜屾湇鍔″櫒楠岃瘉璺敱
Route::group(['prefix' => 'wechat'], function () {
    Route::get('/menu/create', [H5Controller::class, 'createMenu'])->name('wechat.menu.create');
    Route::get('/menu/delete', [H5Controller::class, 'deleteMenu'])->name('wechat.menu.delete');
    Route::get('/menu/get', [H5Controller::class, 'getMenu'])->name('wechat.menu.get');
    Route::get('/verify', [WechatVerifyController::class, 'verify'])->name('wechat.verify');
    Route::post('/verify', [WechatVerifyController::class, 'handleMessage'])->name('wechat.message');
});

// 门店端路由
Route::group(['prefix' => 'store'], function () {
    Route::get('/', [StoreController::class, 'index'])->name('store.index');
});
Route::get('/store/{any}', [StoreController::class, 'index'])
    ->where('any', '^(?!wechat\/)(?!assets\/)(?!static\/).*$')
    ->name('store.history');
